﻿using BusinessEntity;
using BusinessRepository;
using learun.util;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace BusinessRule
{
   public class CsRule
    {

        public async static void GetcsTrans()
        {
            Transaction transaction = new Transaction();
            try
            {
               
                IRepository irp1 = transaction.AddIRepository("1");

                IRepository irp2 = transaction.AddIRepository("c1", "t1", "2");

                await irp1.ExecuteSql(@"update ACatalog
set remark = 'aaaaaaaaaaaaaaaaaaaaaaa'
where id = 'c1'
");

                await irp2.ExecuteSql("insert into aaaaa(year) values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')");

                await irp2.ExecuteSql("insert into aaaaa(year) values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')");

                transaction.Commit();
            }
            catch (Exception ex)
            {
                transaction.RollBack();
            }

        }

        public Task<dynamic> GetCS()
        {
           string strid = CommonHelper.GetUniqueId().ToString();



           return new RepositoryFactory().BaseRepository(ConfigHelper.GetConfig().dbConn, ConfigHelper.GetConfig().dbType).FindEntity<dynamic>("select * from ADataPower where id = '201306181438299651'");

            //return JsonConvert.SerializeObject(vars);
        }

        public async Task<dynamic> GetCS2()
        {
            string strid = CommonHelper.GetUniqueId().ToString();



            return await new RepositoryFactory().BaseRepository(ConfigHelper.GetConfig().dbConn, ConfigHelper.GetConfig().dbType).FindEntity<dynamic>("select * from ADataPower where id = '201306181438299651'");

            //return JsonConvert.SerializeObject(vars);
        }
    }
}
